package cn.yusei.teamTribe.entity;

public class UserInfo {
	
	private int id;
	private String nickname;
	private String portrait;
	private String createTime;
	private int isPublic;
	
	private Student student;

	/**
	 * 		可以选择是否隐藏的资料个数
	 */
	private static final int fieldNum;
	
	static
	{
		fieldNum = Student.class.getDeclaredFields().length;
	}
	
	public UserInfo()
	{
		student = new Student();
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public String getPortrait() {
		return portrait;
	}
	public void setPortrait(String portrait) {
		this.portrait = portrait;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public int getIsPublic() {
		return isPublic;
	}
	public void setIsPublic(int isPublic) {
		this.isPublic = isPublic;
	}
	
	public boolean isValid()
	{
		if(id <= 0)
			return false;
		if(nickname == null || nickname.length() == 0 || nickname.length() > 16)
			return false;
		if(portrait == null || portrait.length() != 32)
			return false;
		if(portrait == null)
			return false;
		if(isPublic  < 0 || isPublic >=  (1 << fieldNum))
			return false;
		return true;
	}
	
	public Student getStudent() {
		return student;
	}
	public void setStudent(Student student) {
		this.student = student;
	}
	
	public String getNo() {
		return student.getNo();
	}
	public void setNo(String no) {
		this.student.setNo(no);
	}
	public int getSchoolId() {
		return student.getSchoolId();
	}
	public void setSchoolId(int schoolId) {
		this.student.setSchoolId(schoolId);
	}
	public String getName() {
		return student.getName();
	}
	public void setName(String name) {
		this.student.setName(name);
	}
	public int getGender() {
		return student.getGender();
	}
	public void setGender(int gender) {
		this.student.setGender(gender);
	}
	public String getBirthday() {
		return student.getBirthday();
	}
	public void setBirthday(String birthday) {
		this.student.setBirthday(birthday);
	}
	public String getAcademy() {
		return student.getAcademy();
	}
	public void setAcademy(String academy) {
		this.student.setAcademy(academy);
	}
	public String getMajor() {
		return student.getMajor();
	}
	public void setMajor(String major) {
		this.student.setMajor(major);
	}
	public int getGrade() {
		return student.getGrade();
	}
	public void setGrade(int grade) {
		this.student.setGrade(grade);
	}
	public int getCla() {
		return this.student.getCla();
	}
	public void setCla(int cla) {
		this.student.setCla(cla);;
	}

	/**
	 * 根据 isPublic 隐藏数据
	 * @throws IllegalAccessException 
	 * @throws IllegalArgumentException 
	 */
	public void updatePublic()
	{
		student.updatePublic(isPublic);
	}
}
